<?php

namespace Admin\Controller;
use User\Api\UserApi;

/**
 * 后台用户控制器
 * @author 麦当苗儿 <zuojiazi@vip.qq.com>
 */
class AdController extends AdminController {
	
	public function _initialize(){
		
		//查询所有广告分类
		$type['pid'] = array('eq',12);
		$type['status'] = array('eq',1);
		$this->assign("typelist",M('category')->where($type)->order('sort asc')->select());
		parent::_initialize();
	}
	public function add(){
		if(IS_POST){

			$dde = D('Ad')->create();
			if($dde){
				D('Ad')->add($_POST);
				$this->success('添加成功',U('ad/index'));
			}else{
				$this->error(D('Ad')->getError());
			}
		}else{
			$this->display();
		}

	}



	public function _filter(&$sqlWhere){
		
		if(!empty($_GET['name'])){
			
			$sqlWhere['name'] = array('like','%' . $_GET['name'] . '%');
		}	
		
		return $sqlWhere;
		
	}
	/* public function _before_add(){
		
	} */
}
